$(function () {
    loading();
    var pageNum = 1;
    ajaxGetUserMsg(pageNum);
    flushUser();
});
/**
 * 获取用户消息
 * @param pageNum 页码
 */
function ajaxGetUserMsg(pageNum) {
    var url = "/Lvscore_User_M/msg/ajaxGetUserMsg";
    $.post(url, {
        pageNum: pageNum
    }, function (data) {
        var h = "<h1>系统消息</h1>";
        if(data.pages==0){
            h = h + "<div class='information' style='margin-top:100px;background-color:#ecf1f8'><center><span style='font-weight:bold;font-size: 25px'>(^・ω・^ )( ^・ω・^)暂无消息(^・ω・^ )( ^・ω・^)</span></center></div>";
        }
        $.each(data.msg, function (index, msg) {
            h = h + "<div class='information'>";
            if (msg.msg_state == 0) {
                h = h + "<span style='font-weight:bold'>";
            } else {
                h = h + "<span>";
            }
            h = h + "<p class='inline-block informTitle'><img src='/Lvscore_User_M/userWeb/static/images/tips.png' alt=''>【" + msg.msg_prefix + "】</p>";

            h = h + "<a href='/Lvscore_User_M/userWeb/views/information/informationDetail.html?msgId=" + msg.id + "' title='点击查看' class='inline-block'>" + msg.msg_title + "</a></span>" +
                "</div>";
        });
        $("#mainText").empty();
        $("#mainText").append(h);
        if ($(".tcdPageCode").html() == "") {
            creatPage(data.pages, data.pageNum);
        }
        $(".loadingBox").hide();
    }, "json")
}
function creatPage(pages, pageNum) {
    if(pages>1){
        $(".tcdPageCode").createPage({
            pageCount: pages,
            current: pageNum,
            backFn: function (p) {
                ajaxGetUserMsg(p);
            }
        });
    }
}